//ok
namespace hjc {

	export class Line {

		//直线方程 Ax+By+C=0
		private $A: number;
		private $B: number;
		private $C: number;

		constructor(angle: number, point: egret.Point);//角点式
		constructor(pA: egret.Point, pB: egret.Point);//两点式
		constructor(p: egret.Point, k: number);//点斜式
		constructor(k: number, h: number);//截距式: y=kx+h
		constructor(A: number, B: number, C: number);//参数式: Ax+By+C=0
		constructor(...params: any[]) {
			if (params.length === 2) {
				let [p1, p2] = params;
				if (numeric(p1) && p2 instanceof egret.Point) {//角点式
					let [angle, point] = [p1, p2];
					this.$B = 1;
					this.$A = -Math.tan(-angle * Math.PI / 180);
					this.$C = this.$B * point.y - this.$A * point.x;
				} else if (p1 instanceof egret.Point && p2 instanceof egret.Point) {//两点式
					let [pA, PB] = [p1, p2];
					//todo ...
				} else if (p1 instanceof egret.Point && numeric(p2)) {//点斜式
					let [p, k] = [p1, p2];
					//todo ...
				} else if (numeric(p1) && numeric(p2)) {//截距式
					let [k, h] = [p1, p2];
					//todo ...
				}
			} else if (params.length === 3) {//参数式
				let [A, B, C] = params;
				this.$A = A;
				this.$B = B;
				this.$C = C;
			}
		}

		//计算距离
		public disTo(p: egret.Point): number;
		public disTo(l: hjc.Line): number;
		public disTo(target: egret.Point | hjc.Line): number {
			if (target instanceof egret.Point) return Math.abs((this.$A * target.x - this.$B * target.y + this.$C) / Math.sqrt(this.$A * this.$A + 1));
			else if (target instanceof hjc.Line) return utils.disOfLines(this,target);
		}
	}
}